import Vue from 'vue'

/**
 * save
 * @param  {[type]}   param [description]
 * @return {[type]}         [description]
 * @author ChenPF
 * @create 2017-04-08
 */
export const save = (${modelName?uncap_first}) => {
  let param = Vue.clone(${modelName?uncap_first})
  if (!param.parentId || param.parentId === '') {
    delete param.parentId
  }
  delete param.id
  return Vue.fetch.post('/${moduleName}/${requestMapping}/save', param)
}

/**
 * update
 * @param  {[type]}   param [description]
 * @return {[type]}         [description]
 * @author ChenPF
 * @create 2017-04-08
 */
export const update = (${modelName?uncap_first}) => {
  return Vue.fetch.post('/${moduleName}/${requestMapping}/update', ${modelName?uncap_first})
}

/**
 * get
 * @param  {[type]}   param [description]
 * @return {[type]}         [description]
 * @author ChenPF
 * @create 2017-04-08
 */
export const get = (${modelName?uncap_first}) => {
  return Vue.fetch.post('/${moduleName}/${requestMapping}/get', ${modelName?uncap_first})
}

/**
 * del
 * @param  {[type]}   param [description]
 * @return {[type]}         [description]
 * @author ChenPF
 * @create 2017-04-08
 */
export const del = (${modelName?uncap_first}) => {
  return Vue.fetch.post('/${moduleName}/${requestMapping}/delete', ${modelName?uncap_first})
}

/**
 * getColumns
 * @param  {[type]}   param [description]
 * @return {[type]}         [description]
 * @author ChenPF
 * @create 2017-04-08
 */
export const getColumns = (params) => {
  return Vue.fetch.get('/common/loadColumns?className=' + params.className, params)
}
